import React, { Fragment } from 'react'
import { Button } from 'antd-mobile'
import { withRouter } from 'react-router-dom'
import './style.scss'

function Success(props) {
  const searchParams = new URLSearchParams(window.location.search)
  const from = searchParams.get('from')
  console.log(from)

  return (
    <div className="success">
      <div className="result">
        <img src={require('../../assets/images/success.png')}/>
        <p className="title">您的订单已经受理！</p>
      </div>
      <div className="content">
        <p className="message">
          号卡购买需符合国家实名制相关规定，我们会尽快审核
        </p>
        <p className="message">
          {from !== 'chinanet' && (
            <span>并通过短信告知受理结果。</span>
          )}

        </p>
        <p className="message">
          审核通过后，我们将<span>委托快递人员为您{from === 'chinanet' ? '送货上门' : '上门激活号卡'}</span>，
        </p>
        <p className="message">
          {from === 'chinanet' ? (
            <Fragment>收到货后，按照说明书操作激活，<span>激活后即可使用。</span></Fragment>
          ) : (
            <Fragment>请提前准备好本人身份证，<span>号卡将在激活后交付您使用。</span></Fragment>
          )}
        </p>
        <p>
          <img src={require('../../assets/images/qrcode.jpg')} alt=""/>
        </p>
        <p>长按识别二维码关注"众民翼起来"公众号</p>
        {from !== 'chinanet' && (
          <p>
            <Button onClick={() => {
              window.location.href = `/?code=${props.match.params.code}`
            }}>确定</Button>
          </p>
        )}
      </div>
    </div>
  )
}

export default withRouter(Success)
